import request from "@/utils/request";
import axios from 'axios';
// const CancelToken = axios.CancelToken;
// const source = CancelToken.source();

// 获取列表
export function getAllList(query) {
  return request({
    url: "/report/page",
    method: "get",
    params: query,
  });
}
// 获取历史版本
export function getHisList(query) {
  return request({
    url: "/report/getHistoryReportByTaskId",
    method: "get",
    params: query,
  });
}
// 获取报告信息
export function getReport(id) {
  return request({
    url: `/report/getReportByTaskId?id=` + id,
    method: "get",
  });
}

// 上传报告信息
export function uploadReport(data) {
  return request({
    url: '/report/uploadReport',
    method: "post",
    data: data,
  });
}

// 生成报告信息-简本报告
export function reportCreat(data, cancel) {
  return request({
    url: '/report/createReport',
    method: "post",
    data: data,
    cancelToken: new axios.CancelToken(function executor(c) {
      cancel.c = c;
    })
  });
}
// 生成报告信息-详本报告
export function detailReportCreat(data, cancel) {
  return request({
    url: '/report/createDetailedReport',
    method: "post",
    data: data,
    cancelToken: new axios.CancelToken(function executor(c) {
      cancel.c = c;
    })
  });
}

// 取消生成
export function canceCreat(data, cancel) {
  return request({
    url: '/report/createReport',
    method: "post",
    data: data,
    // cancelToken: source.token
    //中止请求
    cancelToken: new axios.CancelToken(function executor(c) {
        cancel.cancel = c;
    })
  });
}

//提交审核
export function submitReview(id) {
  return request({
    url: '/report/submitReview',
    method: "post",
    data:{
    	reportId: id
    }
    
  });
}

// 现场调查报告-获取列表
export function getSamplingReport(query) {
  return request({
    url: "/samplingReport/page",
    method: "get",
    params: query,
  })
}

// 现场调查报告-获取报告信息
export function getSamplingReportInfo(id) {
  return request({
    url: `/samplingReport/getReportByTaskId?id=` + id,
    method: "get"
  })
}

// 现场调查报告-生成报告  
export function creatSamplingReport(data, cancel){
  return request({
    url: "/samplingReport/createReport",
    method: "post",
    data,
    cancelToken: new axios.CancelToken(function executor(c) {
      cancel.c = c;
    })
  })
}
export function cancelSamplingCreat(data) {
  return request({
    url: '/samplingReport/createReport',
    method: "post",
    data: data,
    //中止请求
    cancelToken: new axios.CancelToken(function executor(c) {
        cancel.cancel = c;
    })
  })
}

// 现场调查报告-获取历史版本
export function getSamplingHisList(query) {
  return request({
    url: "/samplingReport/getHistoryReportByTaskId",
    method: "get",
    params: query,
  });
}


// 获取报告模板
export function getReportTemplateByType(rtType) {
  return request({
    url: `/fxfzypg/report/getReportTemplateByType?rtType=${rtType}`,
    method: "get"
  })
}